﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace SpaceMan.Physics
{
    public class PHY_GravityWell 
    {
        public Vector2 position;
        long mass;

        public PHY_GravityWell(int radius, float MaterialMass, Vector2 position)
        {
            this.position = position;
            mass = (long)((4 / 3 * Math.PI * Math.Pow(radius, 3)) * MaterialMass);
        }

        public void Update(Vector2 position)
        {
            this.position = position;
        }

        public void attract(PHY_Base body)
        {
            Vector2 forcevector = position - body.currentState.Pos;
            float force = (float)(6.6720e-08 * (mass * body.mass) / forcevector.LengthSquared());

            forcevector.Normalize();
            forcevector *= force * S_Global.getTimescale();
            
            body.Addforce(forcevector);
        }
    }
}
